import 'package:gluz/generated/json/base/json_convert_content.dart';
import 'package:gluz/app/data/area_entity.dart';

AreaEntity $AreaEntityFromJson(Map<String, dynamic> json) {
  final AreaEntity areaEntity = AreaEntity();
  final int? country = jsonConvert.convert<int>(json['country']);
  if (country != null) {
    areaEntity.country = country;
  }
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    areaEntity.id = id;
  }
  final int? level = jsonConvert.convert<int>(json['level']);
  if (level != null) {
    areaEntity.level = level;
  }
  final String? mergename = jsonConvert.convert<String>(json['mergename']);
  if (mergename != null) {
    areaEntity.mergename = mergename;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    areaEntity.name = name;
  }
  final int? pid = jsonConvert.convert<int>(json['pid']);
  if (pid != null) {
    areaEntity.pid = pid;
  }
  final String? shortname = jsonConvert.convert<String>(json['shortname']);
  if (shortname != null) {
    areaEntity.shortname = shortname;
  }
  return areaEntity;
}

Map<String, dynamic> $AreaEntityToJson(AreaEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['country'] = entity.country;
  data['id'] = entity.id;
  data['level'] = entity.level;
  data['mergename'] = entity.mergename;
  data['name'] = entity.name;
  data['pid'] = entity.pid;
  data['shortname'] = entity.shortname;
  return data;
}

extension AreaEntityExtension on AreaEntity {
  AreaEntity copyWith({
    int? country,
    int? id,
    int? level,
    String? mergename,
    String? name,
    int? pid,
    String? shortname,
  }) {
    return AreaEntity()
      ..country = country ?? this.country
      ..id = id ?? this.id
      ..level = level ?? this.level
      ..mergename = mergename ?? this.mergename
      ..name = name ?? this.name
      ..pid = pid ?? this.pid
      ..shortname = shortname ?? this.shortname;
  }
}